<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('造句管理列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <p>词：</p>
                                <input type="text" name="ci"/>
                            </li>
                            <li>
                                <p>内容来源：</p>
                                <select name="fromType" th:with="type=${@dict.getType('common_from_type')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">

            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('dict:dictsentence:edit')}]];
        var removeFlag = [[${@permission.hasPermi('dict:dictsentence:remove')}]];
        var fromTypeDatas = [[${@dict.getType('common_from_type')}]];
        var approveStDatas = [[${@dict.getType('common_approve_status')}]];
        var prefix = ctx + "dict/dictsentence";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "造句管理",
                columns: [{
                    checkbox: true
                },
                {
                    field : 'id', 
                    title : 'id',
                    visible: false
                },
                {
                    field : 'ci', 
                    title : '词'
                },
                {
                    field : 'content', 
                    title : '造句'
                },
                {
                    field : 'createdTime', 
                    title : '创建时间'
                },
                {
                    field : 'kkid', 
                    title : '用户ID'
                },
                {
                    field : 'fromType', 
                    title : '内容来源',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(fromTypeDatas, value);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="edit(\'' + row.id + '\',\'' + row.ci + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="remove(\'' + row.id + '\',\'' + row.ci + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function edit(id, ci){
		    var url = prefix + "/edit/" + id + "?ci=" + ci;
		    $.modal.openFull("修改", url);
		}

		function remove(id, ci){
		    var url = prefix + "/remove";
		    $.modal.confirm("确定删除该条信息吗？", function() {
                var data = { "id": id, "ci": ci};
                $.operate.submit(url, "post", "json", data);
            });
		}

    </script>
</body>
</html>